package com.sike.netty.im.client.handler;

import cn.hutool.core.date.DateUtil;
import com.sike.netty.im.client.service.BeanFactory;
import com.sike.netty.im.client.service.LoginService;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import lombok.extern.slf4j.Slf4j;

/**
 * 登录 handler
 *
 * @author chenssy
 * @date 2023/09/14
 */
@Slf4j
public class LoginHandler extends ChannelInboundHandlerAdapter {
    @Override
    public void channelActive(ChannelHandlerContext ctx) throws Exception {
        log.info("{},开始登录,登录时间:{}", ctx.channel(),DateUtil.now());

        LoginService loginService = (LoginService) BeanFactory.getServiceBean(LoginService.class);
        loginService.login(ctx.channel());
    }
}
